package org.hank.wanandroid.http

import org.hank.wanandroid.bean.*
import retrofit2.http.*


interface ApiService {

    //获取首页BANNer
    @GET("banner/json")
    suspend fun getHomeBanner(): HttpWrapBean<MutableList<HomeBannerBean>>

    //获取首页文章
    @GET("article/list/{pageNum}/json")
    suspend fun getHomeArticle(@Path("pageNum") pageNum: Int): HttpWrapBean<PageArticleBean>

    //获取置顶文章
    @GET("article/top/json")
    suspend fun getHomeArticleTop(): HttpWrapBean<MutableList<ArticleBean>>

    //获取个人积分信息
    @GET("lg/coin/userinfo/json")
    suspend fun getIntegral(): HttpWrapBean<IntegralBean>

    //登录
    @FormUrlEncoded
    @POST("user/login")
    suspend fun login(
        @Field("username") username: String,
        @Field("password") password: String,
    ): HttpWrapBean<UserInfo>

    //收藏
    @POST("lg/collect/{articleid}/json")
    suspend fun collect(@Path("articleid") articleid: Int): HttpWrapBean<String?>

    //https://www.wanandroid.com/lg/collect/add/json 收藏站外的文章   方式POST   参数:title，author，link

    //取消收藏
    @POST("lg/uncollect_originId/{articleid}/json")
    suspend fun uncollect(@Path("articleid") article: Int): HttpWrapBean<String?>

    //取消收藏 包括自身的文章 post 参数: id:拼接在链接上 originId:列表页下发，无则为-1
    @POST("lg/uncollect_originId/{articleid}/json")
    suspend fun myUncollect(
        @Path("articleid") article: Int,
        @Body originId: String
    ): HttpWrapBean<Boolean>

    @GET("lg/collect/list/{pageNum}/json")
    suspend fun myCollectList(@Path("pageNum") pageNum: Int): HttpWrapBean<PageArticleBean>

    @GET("user/logout/json")
    suspend fun logout(): HttpWrapBean<Boolean?>

    @POST("article/query/{pageNum}/json")
    @FormUrlEncoded
    suspend fun search(
        @Path("pageNum") pageNum: Int,
        @Field("k") searchKey: String
    ): HttpWrapBean<PageArticleBean>

    @GET("project/tree/json")
    suspend fun getProjectList(): HttpWrapBean<MutableList<ProjectBean>>

    @GET("project/list/{pageNum}/json")
    suspend fun getProjectDetailList(
        @Path("pageNum") pageNum: Int,
        @Query("cid") cid: Int
    ): HttpWrapBean<PageArticleBean>

    @GET("wxarticle/chapters/json")
    suspend fun getWxarticleList(): HttpWrapBean<MutableList<WxArticleBean>>

    @GET("wxarticle/list/{wxid}/{pageNum}/json")
    suspend fun getWxarticleHistory(
        @Path("wxid") id: Int,
        @Path("pageNum") pageNum: Int
    ): HttpWrapBean<PageArticleBean>

    @GET("tree/json")
    suspend fun getTreeList(): HttpWrapBean<MutableList<ProjectBean>>

    @GET("navi/json")
    suspend fun getNaviList(): HttpWrapBean<MutableList<NaviBean>>

    @GET("article/list/{pageNum}/json")
    suspend fun getTreeDetailsList(
        @Path("pageNum") pageNum: Int,
        @Query("cid") id: Int
    ): HttpWrapBean<PageArticleBean>
}